package org.htmlparser.filters;

import java.util.Locale;
import org.htmlparser.Attribute;
import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Tag;

public class HasAttributeFilter
  implements NodeFilter
{
  protected String mAttribute;
  protected String mValue;

  public HasAttributeFilter()
  {
    this("", null);
  }

  public HasAttributeFilter(String paramString)
  {
    this(paramString, null);
  }

  public HasAttributeFilter(String paramString1, String paramString2)
  {
    this.mAttribute = paramString1.toUpperCase(Locale.ENGLISH);
    this.mValue = paramString2;
  }

  public boolean accept(Node paramNode)
  {
    Attribute localAttribute;
    boolean bool = false;
    if (paramNode instanceof Tag)
    {
      localAttribute = ((Tag)paramNode).getAttributeEx(this.mAttribute);
      if (localAttribute == null)
        break label54;
      bool = true;
    }
    while (true)
    {
      if ((bool) && (this.mValue != null))
        bool = this.mValue.equals(localAttribute.getValue());
      return bool;
      label54: bool = false;
    }
  }

  public String getAttributeName()
  {
    return this.mAttribute;
  }

  public String getAttributeValue()
  {
    return this.mValue;
  }

  public void setAttributeName(String paramString)
  {
    this.mAttribute = paramString;
  }

  public void setAttributeValue(String paramString)
  {
    this.mValue = paramString;
  }
}